package br.consultorio.digital.modelo;

import java.util.ArrayList;
import java.util.List;

import android.app.Activity;
import br.consultorio.digital.control.AgendaDataListar;
import br.consultorio.digital.dao.DAOAgendaData;
import br.consultorio.digital.modelo.entidade.AgendaDataAdapter;

/**
 * 
 * @author Paulo
 * 
 */
public class ModelAgendaData {

	private Activity ap;
	private DAOAgendaData DAOad;

	public ModelAgendaData(Activity ap) {
		this.ap = ap;
	}

	public boolean tratarConsultaData(String data) {
		DAOad = DAOAgendaData.getInstance(ap);
		ArrayList<Object> atg = DAOad.consultarDh_agenda(data);
		if (atg != null) {
			AgendaDataAdapter ladapter = new AgendaDataAdapter(
					ap.getApplicationContext(), atg);
			((AgendaDataListar) ap).setListAdapter(ladapter);
			return true;
		}
		return false;
	}

	public boolean tratarConsultaTodos() {
		DAOad = DAOAgendaData.getInstance(ap);
		List<Object> atg = DAOad.consultarTodos();
		if (atg != null) {
			AgendaDataAdapter ladapter = new AgendaDataAdapter(
					ap.getApplicationContext(), atg);
			((AgendaDataListar) ap).setListAdapter(ladapter);
			return true;
		}
		return false;
	}
}
